package com.ma.math;

public class Vector2 {
	 public double X;
     public double Y ;

     static {
    	 ZERO=new Vector2(0, 0);
    	 FORWARD=new Vector2(0, 1);
     }
     
     public  final static Vector2 ZERO;
     
     public final static Vector2 FORWARD;
     public  static Vector2 division (Vector2 a,float cs)
     {
         return new Vector2(a.X / cs, a.Y / cs);
     }
     public  static Vector2 division (Vector2 a,int cs)
     {
         return new Vector2(a.X / cs, a.Y / cs);
     }
     
     public  static Vector2 division (Vector2 a,double cs)
     {
         return new Vector2(a.X / cs, a.Y / cs);
     }

     public static Vector2 multiplication(Vector2 a, float cs)
     {
         return new Vector2(a.X * cs, a.Y * cs);
     }


     public static Vector2 multiplication(Vector2 a, int cs)
     {
         return new Vector2(a.X * cs, a.Y * cs);
     }
     
     public static Vector2 multiplication(Vector2 a,double cs)
     {
         return new Vector2(a.X * cs, a.Y * cs);
     }

     public static Vector2 subtraction(Vector2 a, Vector2 cs)
     {
         return new Vector2(a.X - cs.X, a.Y - cs.Y);
     }

     public static Vector2 inverse(Vector2 a)
     {
         return new Vector2(-a.X , -a.Y);
     }

     public static Vector2 addition(Vector2 a, Vector2 cs)
     {
         return new Vector2(a.X + cs.X, a.Y + cs.Y);
     }

     public Vector2(int x, int y)
     {
         X = x;
         Y = y;
     }

     public Vector2(float x, float y)
     {
         X = x;
         Y = y;
     }
     
     public Vector2(double x, double y)
     {
         X = x;
         Y = y;
     }



     public double Magnitude()
     {
         return Math.sqrt((X * X) + (Y * Y));
     }

     public Vector2 Nomalize()
     {
        return Vector2.division(this, this.Magnitude());
     }

    

    

    

     public static double Distance(Vector2 a, Vector2 b)
     {
         double a2 = Math.abs(a.X - b.X);
         double b2 = Math.abs(a.Y - b.Y);

         return Math.sqrt(a2 * a2 + b2 * b2);
     }

     public static double Dot(Vector2 a, Vector2 b)
     {
         return (a.X * b.X) + (a.Y * b.Y);
     }

     public static double Angle(Vector2 a, Vector2 b)
     {
         return Math.acos(Dot(a.Nomalize(), b.Nomalize()));
     }

     public static Vector2 Rotate(Vector2 iA, double degrees)
     {
         degrees =Math.toRadians(degrees);
         Vector2 A = new Vector2(0, 0);
         A.X = (iA.X * Math.cos(degrees) - iA.Y * Math.sin(degrees));
         A.Y = (iA.X  * Math.sin(degrees) + iA.Y * Math.cos(degrees));
         
         return A;
     }

     public static Vector2 SetVertex(double X,double Y)
     {
         return  new Vector2(X, Y);
     }
	@Override
	public String toString() {
		return "Vector2 [X=" + X + ", Y=" + Y + "]";
	}

   
}
